package sort.cmp;

import sort.Sort;

/**
 * @Author: LDeng
 * @Date: 2021-03-24 13:03
 */
public class InsertionSort2<E extends Comparable<E>> extends Sort<E> {
    @Override
    protected void sort() {
        for (int begin = 1; begin < array.length; begin++) {
            int current=begin;//原来的位置
            E e=array[current];
            while (current>0 && cmp(e,array[current-1])<0){
               array[current]=array[current-1];
                current=current-1;
            }
            array[current]=e;
        }
    }
}
